package org.samoji.model;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class Database {

    private static Database istanza = null;
    private static Connection conn = null;
    private static String host = "linux3.dti.supsi.ch:1521";
    private static String user = "scannapieco";
    private static String pass = "oraclei3a";
    private static String db = "o102";

    private Database() throws ClassNotFoundException, SQLException {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        Database.conn = (Connection) DriverManager.getConnection("jdbc:oracle:thin:@" + Database.host + ":" + Database.db, Database.user, Database.pass);
    }

    public static Database getInstance() {
        if (istanza == null) {
            try {
                istanza = new Database();
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException ex) {
                Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return istanza;
    }

    public Connection getConnection() {
        return Database.conn;
    }
}